package xyz.lwm.lazycat.aop.matcher;

import xyz.lwm.lazycat.utility.matcher.Matcher;
import xyz.lwm.lazycat.utility.scan.PathRegex;

class StringPatternMatcher implements Matcher<String> {

    private final PathRegex regex;

    public StringPatternMatcher(String pattern) {
        PathRegex regex = PathRegex.toRegex(pattern.replace(".", "/"));
        this.regex = new PathRegex(regex.toString().replace("/", "."));
    }

    @Override
    public boolean matches(String target) {
        return regex.matches(target);
    }

}
